package mvp.demo.V.activity;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import mvp.demo.P.IPresenter;
import mvp.demo.V.IView;

public abstract class BaseActivity extends AppCompatActivity implements IView {

    protected IPresenter presenter;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        presenter = createPresenter();
        presenter.attachView(this);

        setupView();
    }

    protected abstract IPresenter createPresenter();

    protected abstract void setupView();


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (presenter != null) {
            presenter.detachView(this);
        }
    }
}
